import math
from matplotlib import pyplot
import itertools
import pylab

nombre='E5U20W2.0'
cabecera='conHVA'
cuales=['0.05','0.1','0.2','0.5','1','2','5','10','20','40','60','100','200']
cuales=['0.05','5','10','20','40','60','100']
dir='/home/jcfernandez/resultados/eps1/u0/AMPL/W2.0/CONNECT/'
dir='/home/jcfernandez/resultados/eps5/u20/AMPL/W2.0/CONNECT/'
colors = itertools.cycle(['b', 'g', 'r', 'c', 'm', 'y', 'k'])

fig = pyplot.figure()
ax1 = fig.add_subplot(211)
ax1.set_ylabel('Conectividad horizontal')
ax2 = fig.add_subplot(212, sharex=ax1)
ax2.set_ylabel('Conectividad vertical')
ax2.set_xlabel('Tiempo')
ax1.set_title(nombre)
for i in range(len(cuales)):
    color = colors.next()
    name=dir+cabecera+cuales[i]+'.dat'
    tim=[]
    H=[]
    V=[]
    for line in file(name):
        line=line.replace('\n','')
        res=[]
        val=line.split(' ')
        for v in val:
            if v!='':
                res.append(float(v))
        if res[0]>0.001:
            tim.append(res[0])
            H.append(res[1])
            V.append(res[2])
    ax1.plot(tim,H,c=color)
    
    
    ax2.plot(tim,V,c=color)
    #ax2.set_ylabel('between y1 and 1')
pylab.legend(tuple(cuales), shadow = True, loc = (0.9, 1.5))
pyplot.savefig(dir+nombre+'.png', format='png')
pyplot.show()